package com.yunji.cabinet.context.convert;

import com.yunji.cabinet.domain.FillCargoInfoDO;
import com.yunji.cabinet.domain.MaintainDO;
import com.yunji.cabinet.vo.MaintainDetailVO;
import com.yunji.cabinet.vo.MaintainVO;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.product.cache.ProductCache;

import java.util.ArrayList;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.cabinet.engine
 * @Title: MaintainConvert
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-11-02 10:08:15      V1.0        HuaAo       新建类
 */

public class MaintainConvert {

    public static List<MaintainVO> convertVO(List<MaintainDO> maintainList) {
        List<MaintainVO> voList = new ArrayList<>();
        for (MaintainDO maintain : maintainList) {
            MaintainVO vo = new MaintainVO();
            BeanUtils.clone(maintain, vo);
            voList.add(vo);

        }
        return voList;
    }

    public static List<MaintainDetailVO> convertDetailVO(List<FillCargoInfoDO> infoList) {
        List<MaintainDetailVO> voList = new ArrayList<>();
        for (FillCargoInfoDO maintain : infoList) {
            MaintainDetailVO vo = new MaintainDetailVO();
            BeanUtils.clone(maintain, vo);
            vo.setProductType(ProductCache.getProductTypeName(ProductCache.getProductType(vo.getProductId())));
            vo.setSku(ProductCache.getProduct(vo.getProductId()).getSku());
            voList.add(vo);
        }
        return voList;
    }
}